home *** CD-ROM | disk | FTP | other *** search
- -- 2000.03.08
- -- Clive Green <clivegreen@atlas.co.uk>
-
- ------------------------------------------------------------------------------------------------------
-
- -- taps into features of the Buddy API Xtra:
-
- ------------------------------------------------------------------------------------------------------
-
- -- declare properties:
- property main -- main code directory object
- property xtraName -- starting string of the name under which the buddyAPI xtra is known
-
- ------------------------------------------------------------------------------------------------------
-
- on new me,L
-
- -- (1) extract and check arguments:
-
- -- check for a parameter list:
- if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"buddyAPIxtra:new"]
-
- -- a reference to the parent codebase is REQUIRED:
- main = L[#main]
- if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"buddyAPIxtra:new"]
-
- --------------------
-
- -- (2) make platform-specific preparations:
- um = main.getUtilityMethods()
- p = um.thePlatform()
-
- if (p = #PC) then
-
- -- for Windows ONLY, we need a userName and registration number in order to initialise
- -- this xtra for use:
-
- -- get the data manager:
- dm = main.getDataManager()
- if (ilk(dm) <> #instance) then return dm
-
- -- obtain data set:
- d = dm.getData([#set:#settings, #item:#buddyRegData])
- if stringP(d[#error]) then return d
- a = d[#name]
- b = d[#code]
-
- -- we need a string and an integer to proceed:
- if not stringP(a) or not integerP(b) then return ¬
- [#error:#badRegDataSupplied, #msg:"buddyAPIxtra:new"]
-
- -- attempt to register the Buddy xtra prior to use:
- n = baRegister(a,b)
- if not(n) then return [#error:#registrationFailed, #msg:"buddyAPIxtra:new"]
-
- end if
-
- --------------------
-
- -- pass back validated manager object to the caller:
- return me
-
- ----------------------------------------------------------------------------------------------------
-
- on driveIsCDROM me,n
-
- -- indicate whether the drive letter supplied is a CD-ROM drive:
- return (baDiskInfo(n,"type") = "CD-ROM")
-
- ----------------------------------------------------------------------------------------------------
-
- on fileExists me,f
-
- -- check argument is a populated string:
- if not stringP(f) then return ¬
- [#error:#noFilePathSupplied, #msg:"buddyAPIxtra:fileExists"]
-
- if not length(f) then return ¬
- [#error:#emptyFilePathSupplied, #msg:"buddyAPIxtra:fileExists"]
-
- --------------------
-
- -- pass back the filePath if it actually points to a existing file:
- if baFileExists(f) then return f
-
- -- flag failure:
- return [#error:#fileNotFound, #msg:"buddyAPIxtra:fileExists" && f]
-
- ----------------------------------------------------------------------------------------------------
-
- on launchFile me,L
-
- -- we need a parameter listing:
- if ilk(L) <> #propList then return ¬
- [#error:#noParamListSupplied, #msg:"buddyAPIxtra:launchCDfile"]
-
- -- extract the filePath supplied:
- f = L[#filePath]
-
- if not stringP(f) then return ¬
- [#error:#badFilePathSupplied, #msg:"buddyAPIxtra:launchCDfile"]
-
- --------------------
-
- -- check file f's existence:
- f = me.fileExists(f)
- if not stringP(f) then return f
-
- -- in what manner should the file f be opened?
- s = L[#state]
- if not stringP(s) then s = "Normal"
-
- --------------------
-
- -- if the file n exists, attempt to open it in the state (s):
- r = baOpenFile(f,s)
-
- -- a buddyAPI integer result of less than 32 indicates an error:
- if r < 32 then return ¬
- [#error:#fileOpenFailure, #msg:"buddyAPIxtra:launchCDfile - budAPI error code:" && r]
-
- -- flag success to the caller:
- return 1
-
- ----------------------------------------------------------------------------------------------------
-
- on getRegistryString me,L
-
- -- This obtains a string value from the windows registry. Note that the error flag (#null) is
- -- returned if the requested value does not exist, or isn't a string.
-
- -- this function is implemented for Windows only:
- um = main.getUtilityMethods()
- p = um.thePlatform()
-
- if (p <> #PC) then return ¬
- [#error:#windowsOnlyMethod, #msg:"buddyAPIxtra:getRegistryString"]
-
- --------------------
-
- -- we need a parameter listing:
- if ilk(L) <> #propList then return ¬
- [#error:#noParamListSupplied, #msg:"buddyAPIxtra:getRegistryString"]
-
- -- extract and (cursorily) check items supplied:
- br = L[#branch]
- if not stringP(br) then return [#error:#badBranchParam, #msg:"buddyAPIxtra:getRegistryString"]
-
- kn = L[#keyName]
- if not stringP(kn) then return [#error:#badKeynameParam, #msg:"buddyAPIxtra:getRegistryString"]
-
- vn = L[#valueName]
- if not stringP(vn) then return [#error:#badValuenameParam, #msg:"buddyAPIxtra:getRegistryString"]
-
- --------------------
-
- -- what string returned represents an error?
- em = "#null"
-
- -- attempt to extract the registry string value:
- s = baReadRegString(kn,vn,em,br)
-
- -- pass back the result:
- if s = em then return [#error:#readRegStringFailure, #msg:"buddyAPIxtra:getRegistryString"]
- return s
-
- ----------------------------------------------------------------------------------------------------
-
- on getRegistryValueNames me,L
-
- -- This returns a LINGO linear list containing all the value names listed at a particular windows
- -- registry location. The error flag (#null) is returned if the specified location EITHER does not
- -- exist, or is empty (- the BuddyAPI doesn't seem to care which).
-
- --------------------
-
- -- this function is implemented for Windows only:
- um = main.getUtilityMethods()
- p = um.thePlatform()
-
- if (p <> #PC) then return ¬
- [#error:#windowsOnlyMethod, #msg:"buddyAPIxtra:getRegistryValueNames"]
-
- --------------------
-
- -- we need a parameter listing:
- if ilk(L) <> #propList then return ¬
- [#error:#noParamListSupplied, #msg:"buddyAPIxtra:getRegistryValueNames"]
-
- -- extract and (cursorily) check items supplied:
- br = L[#branch]
- if not stringP(br) then return [#error:#badBranchParam, #msg:"buddyAPIxtra:getRegistryValueNames"]
-
- kn = L[#keyName]
- if not stringP(kn) then return [#error:#badKeynameParam, #msg:"buddyAPIxtra:getRegistryValueNames"]
-
- --------------------
-
- -- pass a LINGO linear list back to the caller:
- return baRegValueList(kn,br)
-
- ----------------------------------------------------------------------------------------------------
-
- on bkgndStage me
-
- -- the baWindowToBack() function doesn't work on the mac:
- um = main.getUtilityMethods()
- p = um.thePlatform()
- if (p <> #PC) then return 1
-
- -- send the projector layer to the back:
- return baWindowToBack(baWinHandle())
-
- ----------------------------------------------------------------------------------------------------
-
- on hideStage me
-
- -- minimise the parent window:
- return baSetWindowState(baWinHandle(),"Minimised")
-
- ----------------------------------------------------------------------------------------------------
-
- on getOSname me
-
- -- what is the current operating system name?
- return baVersion("os")
-
- ----------------------------------------------------------------------------------------------------